Skip to content

Add rfl::cli::OptionsFirst to pass the rest of the command line through - #31

Open
clockblocker wants to merge 1 commit into
wave-base-10from
cli-options-first
Open

clockblocker wants to merge 1 commit into
wave-base-10from
cli-options-first

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the opt-in rfl::cli::OptionsFirst processor so option parsing stops at the first positional argument and all subsequent tokens are passed through verbatim (like POSIX/getopt + mode).

Example

struct Recipe {
  rfl::Short<"v", std::optional<bool>> verbose;
  rfl::Positional<std::string> name;
  rfl::Positional<rfl::DefaultVal<std::vector<std::string>>> args;
};

rfl::cli::read<Recipe, rfl::cli::OptionsFirst>(
    {"-v", "build", "--jobs", "4", "-v", "--", "a,b", ""});
// -> verbose=true, name="build", args={"--jobs", "4", "-v", "--", "a,b", ""}

Key details

  • Default behavior is unchanged when omitted; ignored by non-CLI formats.
  • Before the first positional, options work normally and -- ends options and is dropped. After it, --, -x, --x, commas, and "" are kept intact without splitting.
  • A positional negative number (e.g. -5) also ends options; rfl::NoExtraFields checks only tokens before the first positional.
  • Long-form --args=a,b before the first positional still splits as a normal option.
  • rfl::cli::usage lists options before positionals in the usage line. Docs updated in cli.md.

(Same rfl::cli::Settings vs processor API question as #30.)

AI-authored. Depends on: #30, #36.

@clockblocker
clockblocker changed the base branch from wave-base-7 to wave-base-10 November 14, 2026 13:01
@clockblocker
clockblocker force-pushed the wave-base-10 branch 2 times, most recently from 30b4ec4 to b06e850 Compare November 16, 2026 05:18
@clockblocker
clockblocker force-pushed the cli-options-first branch 2 times, most recently from 2f1c300 to d5c2a1b Compare November 17, 2026 04:36
With rfl::cli::OptionsFirst, the options end at the first positional
argument, as in getopt's '+' mode. Every later token is a positional
argument, taken as it is: `--x`, `-x`, unknown options and `--`. A list
as the last positional field gets the rest of the command line
unchanged, whatever the list delimiter: the arguments are not split at
the commas, and empty ones are kept.

Before the first positional argument, options work as usual, and `--`
ends them and is dropped. After it, `--` is kept. A token read as a
positional argument, such as `-5`, also ends the options. usage lists
the options before the positional arguments in the synopsis.

The setting is off by default, and other formats ignore it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant